// Decompiled on 周六 2月 22 19:31:49 CST 2025 with Zomboid Decompiler v0.1.3 using Vineflower.
package zombie.audio.parameters;

import zombie.audio.FMODGlobalParameter;
import zombie.characters.IsoPlayer;
import zombie.core.Core;

public final class ParameterCameraZoom extends FMODGlobalParameter {
    public ParameterCameraZoom() {
        super("CameraZoom");
    }

    @Override
    public float calculateCurrentValue() {
        IsoPlayer isoPlayer = this.getPlayer();
        if (isoPlayer == null) {
            return 0.0F;
        } else {
            float float0 = Core.getInstance().getZoom(isoPlayer.PlayerIndex) - Core.getInstance().OffscreenBuffer.getMinZoom();
            float float1 = Core.getInstance().OffscreenBuffer.getMaxZoom() - Core.getInstance().OffscreenBuffer.getMinZoom();
            return float0 / float1;
        }
    }

    private IsoPlayer getPlayer() {
        IsoPlayer isoPlayer0 = null;

        for (int _int = 0; _int < IsoPlayer.numPlayers; _int++) {
            IsoPlayer isoPlayer1 = IsoPlayer.players[_int];
            if (isoPlayer1 != null && (isoPlayer0 == null || isoPlayer0.isDead() && isoPlayer1.isAlive())) {
                isoPlayer0 = isoPlayer1;
            }
        }

        return isoPlayer0;
    }
}
